﻿Public Class GeneralForm

    Dim wassaved As Boolean
    Dim wherewassaved As String

#Region "ShowAll and SaveAll"
    Public Sub showall()
        savemini.Enabled = True
        edit.Visible = True
        view.Visible = True
        gadgetsets.Visible = True
        undomini.Enabled = True
        redomini.Enabled = True
        cutmini.Enabled = True
        copymini.Enabled = True
        pastemini.Enabled = True
        explorermini.Enabled = True
        gadgetsetsmini.Enabled = True
        compilemini.Enabled = True
    End Sub

    Public Sub saveall()
        Try
            Dim path As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Gadget Creator\tmp"
            tabcontrol.SelectedIndex = 0
            For Each TabPage In tabcontrol.TabPages
                Dim writer As New System.IO.StreamWriter(path + "\" + tabcontrol.SelectedTab.Name, False, System.Text.Encoding.GetEncoding(1251))
                writer.Write(CType(tabcontrol.SelectedTab.Controls(0), FastColoredTextBoxNS.FastColoredTextBox).Text)
                writer.Close()
                tabcontrol.SelectedIndex = +1
            Next
        Catch ex As Exception
            notify.Text = "Failed to save the project(one of documents). Error:" + ex.Message
            notifier.Visible = True
        End Try
    End Sub
#End Region

    Private Sub GeneralForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If My.Settings.style = "Aero Black" Then
            Dim style As New ToolStripProfessionalRenderer(New AeroBlack)
            MenuStrip1.Renderer = style
            ToolStrip1.Renderer = style
        ElseIf My.Settings.style = "Microsoft Office" Then
            Dim style As New ToolStripProfessionalRenderer(New MicrosoftOffice)
            MenuStrip1.Renderer = style
            ToolStrip1.Renderer = style
        ElseIf My.Settings.style = "Visual Studio" Then
            Dim style As New ToolStripProfessionalRenderer(New VisualStudio)
            MenuStrip1.Renderer = style
            ToolStrip1.Renderer = style
        End If

        wb.Navigate(Application.StartupPath + "\startpage.mht")
        Dim path As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Gadget Creator"
        Try
            System.IO.Directory.CreateDirectory(path)
        Catch ex As Exception

        End Try
        ' Проверка запуска
        Dim file As String = Command$()
        If file = "" Then

        Else
            file = Replace(file, Chr(34), "")
            Dim fileext = System.IO.Path.GetExtension(file)
            If fileext = ".gcp" Then
                Try
                    System.IO.Directory.CreateDirectory(path + "\tmp")
                    Using zip1 As Ionic.Zip.ZipFile = Ionic.Zip.ZipFile.Read(file)
                        Dim y As Ionic.Zip.ZipEntry
                        For Each y In zip1
                            y.Extract(path + "\tmp\", Ionic.Zip.ExtractExistingFileAction.OverwriteSilently)
                        Next
                    End Using
                    ' Создание редактора гаджета(начало)
                    tabcontrol.TabPages.Clear()
                    Dim gadgetpage As New TabPage
                    gadgetpage.Text = "Gadget"
                    Dim htmlbox As New FastColoredTextBoxNS.FastColoredTextBox
                    htmlbox.Language = FastColoredTextBoxNS.Language.HTML
                    htmlbox.Text = My.Settings.gadgetsyntax
                    htmlbox.Dock = DockStyle.Fill
                    gadgetpage.Controls.Add(htmlbox)
                    gadgetpage.Name = "gadget.html"
                    tabcontrol.TabPages.Add(gadgetpage)
                    Dim htmlwriter As New System.IO.StreamWriter(path + "\gadget.html", True, System.Text.Encoding.GetEncoding(1251))
                    htmlwriter.Write(htmlbox.Text)
                    htmlwriter.Close()
                    tabcontrol.SelectedTab = gadgetpage

                    ' Создание редактора гаджета(конец)

                    browser.Checked = True
                    browsefiles.Visible = True
                    refreshfiles()
                    wassaved = True
                    wherewassaved = file
                    notifier.Visible = True
                    notify.Text = "Project loaded succesfully!"
                    showall()
                Catch ex As Exception
                    notifier.Visible = True
                    notify.Text = "Failed to load project. Error: " + ex.Message
                    Dim player As New System.Media.SoundPlayer
                    player.Stream = My.Resources.notfound
                    player.Play()
                End Try
            Else
                MsgBox("File with extension " + fileext + ", is not a project.", 48, "Fail")
                Dim player As New System.Media.SoundPlayer
                player.Stream = My.Resources.notfound
                player.Play()
            End If
        End If
    End Sub
    Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click, newmini.Click
        If MsgBox("All unsaved data will be lost. Continue?", 36, "Gadget Creator") = MsgBoxResult.Yes Then

            tabcontrol.TabPages.Clear()
            Dim gadgetpage As New TabPage
            ' Удаление временной директории
            Try
                Dim path As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Gadget Creator\tmp"
                If System.IO.Directory.Exists(path) = True Then
                    System.IO.Directory.Delete(path, True)
                    System.IO.Directory.CreateDirectory(path)
                Else
                    System.IO.Directory.CreateDirectory(path)
                End If
                Dim writer As New System.IO.StreamWriter(path + "\gadget.xml", True, System.Text.Encoding.UTF8)
                writer.Write(My.Resources.xmldefault)
                writer.Close()
                ' Создание редактора гаджета(начало)

                gadgetpage.Text = "Gadget"
                Dim htmlbox As New FastColoredTextBoxNS.FastColoredTextBox
                htmlbox.Language = FastColoredTextBoxNS.Language.HTML
                htmlbox.Text = My.Settings.gadgetsyntax
                htmlbox.Dock = DockStyle.Fill
                gadgetpage.Controls.Add(htmlbox)
                gadgetpage.Name = "gadget.html"
                tabcontrol.TabPages.Add(gadgetpage)
                Dim htmlwriter As New System.IO.StreamWriter(path + "\gadget.html", True, System.Text.Encoding.GetEncoding(1251))
                htmlwriter.Write(htmlbox.Text)
                htmlwriter.Close()

                ' Создание редактора гаджета(конец)

                showall()

            Catch ex As Exception
                notify.Text = "While project was creating, an error occurred: " + ex.Message
            End Try

            browser.Checked = True
            browsefiles.Visible = True
            refreshfiles()

            tabcontrol.SelectedTab = gadgetpage
            wassaved = False
            If My.Settings.professional = True Then
                XMLEditor.Show()
            Else
                GadgetSetForm.Show()
            End If
        End If
        wassaved = False
        wherewassaved = ""
    End Sub
    Private Sub СвойстваГаджетаToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles СвойстваГаджетаToolStripMenuItem.Click, gadgetsetsmini.Click
        If My.Settings.professional = True Then
            XMLEditor.Show()
        Else
            GadgetSetForm.Show()
        End If
    End Sub

    Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click, openmini.Click
        Dim path As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Gadget Creator\tmp\"
        Try
            If System.IO.Directory.Exists(path) = True Then
                System.IO.Directory.Delete(path, True)
                System.IO.Directory.CreateDirectory(path)
            Else
                System.IO.Directory.CreateDirectory(path)
            End If
        Catch ex As Exception
            MsgBox(ex.Message, 16, "Gadget Creator")
        End Try
        If MsgBox("All unsaved data will be lost! Continue?", 36, "Gadget Creator") = MsgBoxResult.Yes Then
            Dim ofd As New OpenFileDialog
            ofd.Filter = "Gadget Creator project|*.gcp"
            ofd.Title = "Open project"
            ofd.AddExtension = False
            If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
                Dim fileext As String = System.IO.Path.GetExtension(ofd.FileName)
                If fileext = ".gcp" Then
                    Try
                        Using zip1 As Ionic.Zip.ZipFile = Ionic.Zip.ZipFile.Read(ofd.FileName)
                            Dim y As Ionic.Zip.ZipEntry
                            For Each y In zip1
                                y.Extract(path, Ionic.Zip.ExtractExistingFileAction.OverwriteSilently)
                            Next
                        End Using
                    Catch ex As Exception
                        notify.Text = "Project is broken and can not be loaded(project type is incorrect)!"
                        notifier.Visible = True
                        System.IO.Directory.Delete(path, True)
                        Exit Sub
                    End Try

                    Try
                        If System.IO.File.Exists(path + "\gadget.xml") = False Then
                            notify.Text = "Project is broken and can not be loaded(gadget.xml doesn't exists)!"
                            notifier.Visible = True
                            System.IO.Directory.Delete(path, True)
                            Exit Sub
                        Else
                            tabcontrol.TabPages.Clear()
                            If System.IO.File.Exists(path + "\gadget.html") = False Then
                                Dim creategadgetfile As New System.IO.StreamWriter(path)
                                creategadgetfile.Write(My.Settings.gadgetsyntax)
                                creategadgetfile.Close()
                                Dim gadgetpage As New TabPage
                                gadgetpage.Name = "gadget.html"
                                gadgetpage.Text = "Gadget"
                                Dim htmlbox As New FastColoredTextBoxNS.FastColoredTextBox
                                htmlbox.Language = FastColoredTextBoxNS.Language.HTML
                                htmlbox.Text = My.Settings.gadgetsyntax
                                htmlbox.Dock = DockStyle.Fill
                                gadgetpage.Controls.Add(htmlbox)
                                tabcontrol.TabPages.Add(gadgetpage)
                            Else
                                Dim opengadgetfile As New System.IO.StreamReader(path + "\gadget.html", System.Text.Encoding.GetEncoding(1251))
                                Dim gadgetpage As New TabPage
                                gadgetpage.Name = "gadget.html"
                                gadgetpage.Text = "Gadget"
                                Dim htmlbox As New FastColoredTextBoxNS.FastColoredTextBox
                                htmlbox.Language = FastColoredTextBoxNS.Language.HTML
                                htmlbox.Text = opengadgetfile.ReadToEnd()
                                opengadgetfile.Close()
                                htmlbox.Dock = DockStyle.Fill
                                gadgetpage.Controls.Add(htmlbox)
                                tabcontrol.TabPages.Add(gadgetpage)
                                tabcontrol.SelectedTab = gadgetpage
                                wassaved = True
                                wherewassaved = ofd.FileName
                                browser.Checked = True
                                browsefiles.Visible = True
                                refreshfiles()
                            End If
                            showall()
                            notifier.Visible = True
                            notify.Text = "Project loaded succesfully!"

                        End If
                    Catch ex As Exception
                        notifier.Visible = True
                        notify.Text = "While project was opening, error occurred: " + ex.Message
                    End Try

                Else
                    notifier.Visible = True
                    notify.Text = "File with extension " + fileext + ", is not Gadget Creator project!"
                End If
            End If
        Else

        End If
    End Sub

    Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click, savemini.Click
        If wassaved = True Then
            Dim path As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Gadget Creator\tmp\"
            saveall()
            Try
                Using zip As Ionic.Zip.ZipFile = New Ionic.Zip.ZipFile()
                    Dim filenames As String() = System.IO.Directory.GetFiles(path)
                    zip.AddFiles(filenames, "")
                    zip.Save(wherewassaved)
                End Using
                notify.Text = "Project was saved succesfully!"
                notifier.Visible = True
            Catch ex As Exception
                notify.Text = "Failed to save the project! Error: " + ex.Message
                notifier.Visible = True
            End Try
        Else
            Dim sfd As New SaveFileDialog
            sfd.Filter = "Gadget Creator project|*.gcp"
            sfd.Title = "Save project"
            If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
                saveall()
                Try
                    Dim path As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Gadget Creator\tmp\"
                    Using zip As Ionic.Zip.ZipFile = New Ionic.Zip.ZipFile()
                        Dim filenames As String() = System.IO.Directory.GetFiles(path)
                        zip.AddFiles(filenames, "")
                        zip.Save(sfd.FileName)
                    End Using
                    wassaved = True
                    wherewassaved = sfd.FileName
                    notify.Text = "Project was saved succesfully!"
                    notifier.Visible = True
                Catch ex As Exception
                    notify.Text = "Failed to save the project! Error: " + ex.Message
                    notifier.Visible = True
                End Try
            End If
        End If
    End Sub

    Private Sub UndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UndoToolStripMenuItem.Click, undomini.Click
        CType(tabcontrol.SelectedTab.Controls(0), FastColoredTextBoxNS.FastColoredTextBox).Undo()
    End Sub

    Private Sub RedoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RedoToolStripMenuItem.Click, redomini.Click
        CType(tabcontrol.SelectedTab.Controls(0), FastColoredTextBoxNS.FastColoredTextBox).Redo()
    End Sub

    Private Sub cut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cut.Click, cutmini.Click
        CType(tabcontrol.SelectedTab.Controls(0), FastColoredTextBoxNS.FastColoredTextBox).Cut()
    End Sub

    Private Sub copy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles copy.Click, copymini.Click
        CType(tabcontrol.SelectedTab.Controls(0), FastColoredTextBoxNS.FastColoredTextBox).Copy()
    End Sub

    Private Sub paste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles paste.Click, pastemini.Click
        CType(tabcontrol.SelectedTab.Controls(0), FastColoredTextBoxNS.FastColoredTextBox).Paste()
    End Sub

    Private Sub selectall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles selectall.Click
        CType(tabcontrol.SelectedTab.Controls(0), FastColoredTextBoxNS.FastColoredTextBox).SelectAll()
    End Sub

    Private Sub КомпилироватьToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles КомпилироватьToolStripMenuItem.Click, compilemini.Click
        Try
            saveall()
            '  Начать компиляцию
            ToolStrip1.Enabled = False
            MenuStrip1.Enabled = False
            Dim sfd As New SaveFileDialog
            sfd.Filter = "Windows Sidebar gadget|*.gadget"
            If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
                Dim path As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Gadget Creator\tmp\"
                Using zip As Ionic.Zip.ZipFile = New Ionic.Zip.ZipFile()
                    Dim filenames As String() = System.IO.Directory.GetFiles(path)
                    zip.AddFiles(filenames, "")
                    zip.Save(sfd.FileName)
                End Using
                Try
                    Dim player As New System.Media.SoundPlayer
                    player.Stream = My.Resources.compilecomplete
                    player.Play()
                Catch ex As Exception

                End Try
            End If
            ToolStrip1.Enabled = True
            MenuStrip1.Enabled = True
        Catch ex As Exception
            notify.Text = "Error occurred when you tried to compile project. Error: " + ex.Message
            notifier.Visible = True
            ToolStrip1.Enabled = True
            MenuStrip1.Enabled = True
            Dim player As New System.Media.SoundPlayer
            player.Stream = My.Resources.errorcompile
            player.Play()
        End Try
    End Sub
    Public Sub refreshfiles()
        Try
            ListView1.Items.Clear()
            Dim path As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Gadget Creator\tmp"
            Dim folderInfo As New IO.DirectoryInfo(path)
            Dim arrFilesInFolder() As IO.FileInfo
            Dim fileInFolder As IO.FileInfo
            arrFilesInFolder = folderInfo.GetFiles("*.html")
            For Each fileInFolder In arrFilesInFolder
                ListView1.Items.Add(fileInFolder.Name).StateImageIndex = 0
            Next
            arrFilesInFolder = folderInfo.GetFiles("*.xml")
            For Each fileInFolder In arrFilesInFolder
                ListView1.Items.Add(fileInFolder.Name).StateImageIndex = 1
            Next
            arrFilesInFolder = folderInfo.GetFiles("*.js")
            For Each fileInFolder In arrFilesInFolder
                ListView1.Items.Add(fileInFolder.Name).StateImageIndex = 2
            Next
            arrFilesInFolder = folderInfo.GetFiles("*.txt")
            For Each fileInFolder In arrFilesInFolder
                ListView1.Items.Add(fileInFolder.Name).StateImageIndex = 3
            Next
            arrFilesInFolder = folderInfo.GetFiles("*.css")
            For Each fileInFolder In arrFilesInFolder
                ListView1.Items.Add(fileInFolder.Name).StateImageIndex = 4
            Next
            arrFilesInFolder = folderInfo.GetFiles("*.bmp")
            For Each fileInFolder In arrFilesInFolder
                ListView1.Items.Add(fileInFolder.Name).StateImageIndex = 5
            Next
            arrFilesInFolder = folderInfo.GetFiles("*.gif")
            For Each fileInFolder In arrFilesInFolder
                ListView1.Items.Add(fileInFolder.Name).StateImageIndex = 6
            Next
            arrFilesInFolder = folderInfo.GetFiles("*.jpg")
            For Each fileInFolder In arrFilesInFolder
                ListView1.Items.Add(fileInFolder.Name).StateImageIndex = 7
            Next
            arrFilesInFolder = folderInfo.GetFiles("*.png")
            For Each fileInFolder In arrFilesInFolder
                ListView1.Items.Add(fileInFolder.Name).StateImageIndex = 8
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
        tabcontrol.SelectedIndex = 0
        deletefile.Enabled = True
        Dim path As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Gadget Creator\tmp"
        If ListView1.SelectedItems.Count > 0 Then
            Dim type = ListView1.FocusedItem.Text
            If type = "gadget.xml" Then
                If My.Settings.professional = True Then
                    XMLEditor.Show()
                Else
                    GadgetSetForm.Show()
                End If
                deletefile.Enabled = False
            End If
            If type.EndsWith(".html") = True Then
                If tabcontrol.TabPages.ContainsKey(type) = True Then
                    tabcontrol.SelectTab(type)
                Else
                    Dim editor As New TabPage
                    editor.Text = ListView1.FocusedItem.Text
                    editor.Name = ListView1.FocusedItem.Text
                    Dim htmlbox As New FastColoredTextBoxNS.FastColoredTextBox
                    htmlbox.Language = FastColoredTextBoxNS.Language.HTML
                    Dim reader As New System.IO.StreamReader(path + "\" + ListView1.FocusedItem.Text, System.Text.Encoding.GetEncoding(1251))
                    htmlbox.Text = reader.ReadToEnd
                    reader.Close()
                    htmlbox.Dock = DockStyle.Fill
                    editor.Controls.Add(htmlbox)
                    tabcontrol.TabPages.Add(editor)
                    tabcontrol.SelectedTab = editor
                End If
            End If
            If type.EndsWith(".js") = True Then
                If tabcontrol.TabPages.ContainsKey(type) = True Then
                    tabcontrol.SelectTab(type)
                Else
                    Dim editor As New TabPage
                    editor.Text = ListView1.FocusedItem.Text
                    editor.Name = ListView1.FocusedItem.Text
                    Dim jsbox As New FastColoredTextBoxNS.FastColoredTextBox
                    jsbox.Language = FastColoredTextBoxNS.Language.JS
                    Dim reader As New System.IO.StreamReader(path + "\" + ListView1.FocusedItem.Text, System.Text.Encoding.GetEncoding(1251))
                    jsbox.Text = reader.ReadToEnd
                    reader.Close()
                    jsbox.Dock = DockStyle.Fill
                    editor.Controls.Add(jsbox)
                    tabcontrol.TabPages.Add(editor)
                    tabcontrol.SelectedTab = editor
                End If
            End If
            If type.EndsWith(".css") = True Then
                If tabcontrol.TabPages.ContainsKey(type) = True Then
                    tabcontrol.SelectTab(type)
                Else
                    Dim editor As New TabPage
                    editor.Text = ListView1.FocusedItem.Text
                    editor.Name = ListView1.FocusedItem.Text
                    Dim cssbox As New FastColoredTextBoxNS.FastColoredTextBox
                    Dim reader As New System.IO.StreamReader(path + "\" + ListView1.FocusedItem.Text, System.Text.Encoding.GetEncoding(1251))
                    cssbox.Text = reader.ReadToEnd
                    reader.Close()
                    cssbox.Dock = DockStyle.Fill
                    editor.Controls.Add(cssbox)
                    tabcontrol.TabPages.Add(editor)
                    tabcontrol.SelectedTab = editor
                End If
            End If
            If type.EndsWith(".txt") = True Then
                If tabcontrol.TabPages.ContainsKey(type) = True Then
                    tabcontrol.SelectTab(type)
                Else
                    Dim editor As New TabPage
                    editor.Text = ListView1.FocusedItem.Text
                    editor.Name = ListView1.FocusedItem.Text
                    Dim txtbox As New FastColoredTextBoxNS.FastColoredTextBox
                    txtbox.Language = FastColoredTextBoxNS.Language.Custom
                    Dim reader As New System.IO.StreamReader(path + "\" + ListView1.FocusedItem.Text, System.Text.Encoding.GetEncoding(1251))
                    txtbox.Text = reader.ReadToEnd
                    reader.Close()
                    txtbox.Dock = DockStyle.Fill
                    editor.Controls.Add(txtbox)
                    tabcontrol.TabPages.Add(editor)
                    tabcontrol.SelectedTab = editor
                End If
            End If
            If type.EndsWith(".bmp") = True Or type.EndsWith(".gif") = True Or type.EndsWith(".jpg") = True Or type.EndsWith(".png") = True Then
                MsgBox("You can't open images! Sorry!")
            End If
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        CreateFile.Show()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles deletefile.Click
        If ListView1.SelectedItems.Count > 0 Then
            If tabcontrol.TabPages.ContainsKey(ListView1.FocusedItem.Text) = True Then
                tabcontrol.SelectTab(ListView1.FocusedItem.Text)
                tabcontrol.TabPages.Remove(tabcontrol.SelectedTab)
                Try
                    Dim path As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Gadget Creator\tmp\"
                    IO.File.Delete(path + ListView1.FocusedItem.Text)
                    refreshfiles()
                Catch ex As Exception
                    notify.Text = "File was not deleted... Error: " + ex.Message
                    notifier.Visible = True
                End Try
            Else
            End If
        Else
            notify.Text = "File was not deleted... Sorry!"
            notifier.Visible = True
        End If
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Application.Exit()
    End Sub

    Private Sub ОбозревательФайловToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles browser.Click, explorermini.Click
        If browser.Checked = True Then
            browser.Checked = False
            explorermini.Checked = False
            browsefiles.Visible = False
            refreshfiles()
        Else
            browser.Checked = True
            browsefiles.Visible = True
            explorermini.Checked = True
            refreshfiles()
        End If
    End Sub
    Private Sub ОПрограммеToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ОПрограммеToolStripMenuItem.Click, helpmini.Click
        notify.Text = "Gadget Creator RC2(build 0401). Po4teda Features, 2012."
        notifier.Visible = True
    End Sub

    Private Sub ВызовСправкиToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ВызовСправкиToolStripMenuItem.Click
        Process.Start("http://gadgetcreator.codeplex.com")
    End Sub

    Dim counting = 0
    Private Sub waiting_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles waiting.Tick
        If counting = 7 Then
            notifier.Visible = False
            counting = 0

        Else
            counting = counting + 1
        End If
    End Sub

    Private Sub notifier_VisibleChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles notifier.VisibleChanged
        If notifier.Visible = True Then
            waiting.Start()
        Else
            waiting.Stop()
        End If
    End Sub

    Private Sub GeneralForm_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        Try
            Dim path As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\Gadget Creator\"
            System.IO.Directory.Delete(path, True)
        Catch ex As Exception

        End Try
    End Sub

    Private Sub SettingsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SettingsToolStripMenuItem.Click
        SettingsForm.Show()
    End Sub

End Class